import React from 'react';
import ReactDOM from 'react-dom';
import App from './App';
import './index.css';
import './style/lib/animate.css';
import { Router, Route, hashHistory, IndexRedirect } from 'react-router';
import Page from './components/Page';
import BasicForm from './components/forms/BasicForm';
import BasicTable from './components/tables/BasicTables';
import AdvancedTable from './components/tables/AdvancedTables';
import AsynchronousTable from './components/tables/AsynchronousTable';
import Login from './components/pages/Login';
import Echarts from './components/charts/Echarts';
import Recharts from './components/charts/Recharts';
import Icons from './components/ui/Icons';
import Buttons from './components/ui/Buttons';
import Spins from './components/ui/Spins';
import Modals from './components/ui/Modals';
import Notifications from './components/ui/Notifications';
import Tabs from './components/ui/Tabs';
import Banners from './components/ui/banners';
import Drags from './components/ui/Draggable';
import Dashboard from './components/dashboard/Dashboard';
import Gallery from './components/ui/Gallery';
import NotFound from './components/pages/NotFound';
import BasicAnimations from './components/animation/BasicAnimations';
import ExampleAnimations from './components/animation/ExampleAnimations';
import registerServiceWorker from './registerServiceWorker';


import AppManager from './scenes/systemmanager/appmanager/AppManager'
import AppInstanceManager from './scenes/systemmanager/appmanager/AppInstanceManager'
import MenuManager from './scenes/systemmanager/appmanager/menumanager/MenuManager'
import UserManager from './scenes/systemmanager/usermanager/UserManager'
import RoleManager from './scenes/systemmanager/rolemanager/RoleManager'
import ArchManager from './scenes/systemmanager/archmanager/ArchManager'
import DemoTest from './scenes/systemmanager/DemoTest'


import ProductManager from './scenes/erp/product/ProductManager'
import ProductBrandManager from './scenes/erp/product/ProductBrandManager'
import ProductSpecsManager from './scenes/erp/product/ProductSpecsManager'

import StockManager from './scenes/erp/stock/StockManager'
import StockInputRecordManager from './scenes/erp/stock/StockInputRecordManager'
import StockOutputRecordManager from './scenes/erp/stock/StockOutputRecordManager'
import StockReturnedRecordManager from './scenes/erp/stock/StockReturnedRecordManager'

import DealerManager from './scenes/erp/dealer/DealerManager'

import DealerInfoManager  from './scenes/erp/business/DealerInfoManager'
import ProducerManager from './scenes/erp/business/ProducerManager'

import GoodsManager from './scenes/erp/goods/GoodsManager'

import OrderManager from './scenes/erp/order/OrderManager'

import MaterialSearch from './scenes/erp/market/MaterialSearch'


const Wysiwyg = (location, cb) => {     // 按需加载富文本配置
    require.ensure([], require => {
        cb(null, require('./components/ui/Wysiwyg').default);
    }, 'Wysiwyg');
};

const routes =
    <Route path={'/'} components={Page}>
        <IndexRedirect to="login" />
        <Route path={'app'} component={App}>
            {/*<Route path={'form'}>*/}
                {/*<Route path={'basicForm'} component={BasicForm} />*/}
            {/*</Route>*/}
            {/*<Route path={'table'}>*/}
                {/*<Route path={'basicTable'} component={BasicTable} />*/}
                {/*<Route path={'advancedTable'} components={AdvancedTable} />*/}
                {/*<Route path={'asynchronousTable'} components={AsynchronousTable} />*/}
            {/*</Route>*/}
            {/*<Route path={'chart'}>*/}
                {/*<Route path={'echarts'} component={Echarts} />*/}
                {/*<Route path={'recharts'} component={Recharts} />*/}
            {/*</Route>*/}
            {/*<Route path={'ui'}>*/}
                {/*<Route path={'icons'} component={Icons} />*/}
                {/*<Route path={'buttons'} component={Buttons} />*/}
                {/*<Route path={'spins'} component={Spins} />*/}
                {/*<Route path={'modals'} component={Modals} />*/}
                {/*<Route path={'notifications'} component={Notifications} />*/}
                {/*<Route path={'tabs'} component={Tabs} />*/}
                {/*<Route path={'banners'} component={Banners} />*/}
                {/*<Route path={'wysiwyg'} getComponent={Wysiwyg} />*/}
                {/*<Route path={'drags'} component={Drags} />*/}
                {/*<Route path={'gallery'} component={Gallery} />*/}
            {/*</Route>*/}
            {/*<Route path={'animation'}>*/}
                {/*<Route path={'basicAnimations'} component={BasicAnimations} />*/}
                {/*<Route path={'exampleAnimations'} component={ExampleAnimations} />*/}
            {/*</Route>*/}
            <Route path={'dashboard/index'} component={Dashboard} />
            <Route path={'system'}>
                <Route path={'appmanager'} component={AppManager} />
                <Route path={'appmanager/menumanager'} component={MenuManager} />
                <Route path={'appinstancemanager'} component={AppInstanceManager} />
                <Route path={'usermanager'} component={UserManager} />
                <Route path={'rolemanager'} component={RoleManager} />
                <Route path={'archmanager'} component={ArchManager} />
                <Route path={'demotest'} component={DemoTest} />
            </Route>
            <Route path={'erp'}>
                <Route path={'product'}>
                    <Route path={'manager'} component={ProductManager} />
                    <Route path={'brandmanager'} component={ProductBrandManager} />
                    <Route path={'specsmanager'} component={ProductSpecsManager} />
                </Route>
                <Route path={'stock'}>
                    <Route path={'manager'} component={StockManager} />
                    <Route path={'recordinputmanager'} component={StockInputRecordManager} />
                    <Route path={'recordoutputmanager'} component={StockOutputRecordManager} />
                    <Route path={'recordreturnedmanager'} component={StockReturnedRecordManager} />
                </Route>
                <Route path={'dealer'}>
                    <Route path={'dealermanager'} component={DealerManager} />
                </Route>
                <Route path={'market'}>
                    <Route path={'materialsearch'} component={MaterialSearch} />
                </Route>
                <Route path={'business'}>
                    <Route path={'dealermanager'} component={DealerInfoManager} />
                    <Route path={'producermanager'} component={ProducerManager} />
                </Route>
                <Route path={'goods'}>
                    <Route path={'goodsmanager'} component={GoodsManager}/>
                </Route>
                <Route path={'order'}>
                    <Route path={'ordermanager'} components={OrderManager}/>
                </Route>
            </Route>
        </Route>
        <Route path={'login'} components={Login} />
        <Route path={'404'} component={NotFound} />
    </Route>;

ReactDOM.render(
  <Router history={hashHistory}>
      {routes}
  </Router>,
  document.getElementById('root')
);
registerServiceWorker();
